35. Exercise: Sunshine Content Provider and Query
Setup Sunshine's Content Provider and Query
Exercise Code
Exercise: S09.01-Exercise-ContentProviderFoundation
Setup
SOLUTION:
- Create WeatherProvider class (with all empty required functions)
- Write onCreate() function
- Register the provider in the Android Manifest
URIMatcher
SOLUTION:
- Define and add URI’s to the Contract for the authority, paths, and base content uri
- Build URIMatcher with matches for these two different URI’s: Weather table, Weather with date
Query
SOLUTION:
- I'm done!
Test Your Code
SOLUTION:
- Run TestURIMatcher
- Run TestWeatherProvider